 
 <?php   
  //php按中奖比例抽奖
 public function selectTitle()
    {
        //定义奖品1，2，3的中奖概率
        $pro = [
            '1' =>16,
            '2' =>29,
            '3' =>55,
        ];
        $ret = '';
        $sum = array_sum($pro);
        foreach($pro as $k => $v) {
            $r = mt_rand(1, $sum);
            if($r <= $v){
                $ret = $k;
                break;
            } else {
                $sum = max(0, $sum - $v);
            }
        }
        if ($ret == 1) {
            $res = "奖品1";
        } elseif ($ret ==2) {
            $res = "奖品2";
        } elseif ($ret ==3) {
            $res = "奖品3";
        }
        return $res;

    }